# @Version        : 1.0
# @Update Time    : 2025/8/25 23:14
# @File           : chart_render.py
# @IDE            : PyCharm
# @Desc           : 文件描述信息

from typing import Iterable, List, Dict

from pyecharts.charts import Page
from pyecharts.charts.chart import Chart


def bundle_into_page(charts: Iterable[Chart]) -> Dict[str, object]:
    page = Page()  # 也可用 Page.DraggablePageLayout
    for c in charts:
        page.add(c)
    return {
        "page_embed": page.render_embed(),
        "page_deps": page.js_dependencies(),
    }


def collect_deps(charts: Iterable[Chart]) -> List[str]:
    deps = set()
    for c in charts:
        deps.update(c.js_dependencies())
    return list(deps)
